package com.miage.m1.xml;

import java.util.Date;

import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

public class Player extends Person{

	private int number;
	private String position;
	private int height;
	private int weight;

/**
 * Create a {@code Player}
 * @param id
 * @param lastName
 * @param firstName
 * @param nationality
 * @param birthday
 * @param height
 * @param weight
 * @param number
 * @param position
 * @param phone
 * @param pay
 * 
 * @see Person#Person(int, String, String, String, Date, String, double)
 */
	public Player(int id, String lastName, String firstName, String nationality, Date birthday, int height, int weight, int number, String position, String phone, double pay) {
		super(id, lastName, firstName, nationality, birthday, phone, pay);
		this.number = number;
		this.position = position;
		this.height = height;
		this.weight = weight;
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param lastName
	 * @param firstName
	 * @param nationality
	 * @param birthday
	 * @param height
	 * @param weight
	 */
	public Player(int id, String lastName, String firstName, String nationality, Date birthday, int height, int weight){
		this(id, lastName, firstName, nationality, birthday, height, weight, 0, "", "", 0);
	}

	/* Methods and Properties*/

	/**
	 * @see Person#Serialize(ContentHandler)
	 */
	public ContentHandler Serialize(ContentHandler handler) throws SAXException{

		atts.addAttribute("","number","number","",String.valueOf(this.getNumber()));
		atts.addAttribute("","height","height","",String.valueOf(this.getHeight()));
		atts.addAttribute("","weight","weight","",String.valueOf(this.getWeight()));
		atts.addAttribute("","id","id","",String.valueOf(this.getId()));
		handler.startElement("", "player", "player", atts);

		handler = super.Serialize(handler);
		atts.clear();
		
		handler.startElement("", "position", "position", atts);
		char[] post = this.getPosition().toCharArray();
		handler.characters(post,0,post.length);
		handler.endElement("", "position", "position");

		handler.endElement("", "player", "player");
		return handler;
	}

/* Getters and Setters */
	public int getNumber() { return number; }

	public void setNumber(int number) { this.number = number; }

	public String getPosition(){ return this.position; }
	
	public int getHeight() { return height;	}

	public void setHeight(int height) { this.height = height; }

	public int getWeight() { return weight;	}

	public void setWeight(int weight) {	this.weight = weight; }

	public void setPosition(String position) { this.position = position; }



}
